package sg.edu.nus.iss.team2s.jass.gui;

import java.awt.Frame;
import java.awt.TextField;
import java.awt.Rectangle;
import java.awt.Button;

import sg.edu.nus.iss.team2s.jass.control.LoginController;
import sg.edu.nus.iss.team2s.jass.dto.User;

public class LoginScreen extends Frame {

	private static final long serialVersionUID = 1L;
	private TextField textField = null;
	private TextField textField1 = null;
	private Button cmd_login = null;

	/**
	 * This is the default constructor
	 */
	public LoginScreen() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setLayout(null);
		this.setSize(300, 200);
		this.setTitle("Frame");

		this.add(getTextField(), null);
		this.add(getTextField1(), null);
		this.add(getCmd_login(), null);
	}

	/**
	 * This method initializes textField	
	 * 	
	 * @return java.awt.TextField	
	 */
	private TextField getTextField() {
		if (textField == null) {
			textField = new TextField();
			textField.setBounds(new Rectangle(41, 66, 113, 26));
		}
		return textField;
	}

	/**
	 * This method initializes textField1	
	 * 	
	 * @return java.awt.TextField	
	 */
	private TextField getTextField1() {
		if (textField1 == null) {
			textField1 = new TextField();
			textField1.setBounds(new Rectangle(40, 109, 115, 32));
		}
		return textField1;
	}

	/**
	 * This method initializes cmd_login	
	 * 	
	 * @return java.awt.Button	
	 */
	private Button getCmd_login() {
		if (cmd_login == null) {
			cmd_login = new Button("Login");
			cmd_login.setBounds(new Rectangle(191, 146, 88, 33));
			cmd_login.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
					User user = validate("", "");
//					if(LoginScreen.this.callBack == null){
//						LoginScreen.this.callBack = new JobAdvertMainScreen();
//					}
//					LoginScreen.this.callBack.setUser(user);
				}
			});
		}
		return cmd_login;
	}
	
	private User validate(String userName, String passWord){
		return LoginController.validateLogin(userName, passWord);
	}

}
